home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
GRAPHICS
/
TS32
/
SPRITEEN.INT
< prev
next >
Wrap
Text File
|
1996-03-21
|
3KB
|
96 lines
unit SpriteEngine;
(***************************************************
TSpriteEngine->TComponent
Manages sprites on a TDIBDrawingSurfaces.
Properties
DIBDrawingSurface-
The TDIBDrawingSurface that will be used to Render
the sprites.
DirtyRectangles-
Determines whether dirty rectangle processing will
be used to render to sprites.
ExpectedSprites-
Set this to the number of sprites you expect to add.
It causes the sprite lists's Capacity property to
be initialized up front.
Sprite[n]-
Returns a specific sprite.
SpriteCount-
The number of registered sprites in the engine.
Events
OnCollision-
Triggered during the execution of the CollisionDetection
method. Returns which two sprites have collided.
Methods
AddSprite-
Add a sprite to the engine.
ChangeSpritePriority-
Safely changes the sprite's priority. Use this
instead of changing the sprite's Priority property
directly.
CollisionDetection-
Performs collision detection within the sprite
engine, or with another sprite engine.
ProcessSprites-
Executes the Move routine of sprites, and does other
processing specific to dirty rectangle system.
RenderSprites-
Draw sprites, using the sprites' Render method. Call
this AFTER calling ProcessSprites.
***************************************************)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DIBDrawingSurface, Sprite, Grafix;
type
TCollisionEvent = procedure( Sender: TObject; Sprite, TargetSprite: TSprite ) of object;
TSpriteEngine = class( TComponent )
private
lstSprites: TList;
lstNewSprites: TList;
lstDeadSprites: TList;
lstDirty: TList;
FDDS: TDIBDrawingSurface;
FDirtyRectangles: boolean;
FExpectedSprites: integer;
FCollision: TCollisionEvent;
bDrawAll: boolean;
protected
function GetSprite( n: integer ): TSprite;
function GetSpriteCount: integer;
procedure SetExpectedSprites( n: integer );
procedure Notification( AComponent: TComponent; Operation: TOperation ); override;
procedure SetDirty( b: boolean );
procedure SetDDS( dds: TDIBDrawingSurface );
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
procedure AddSprite( spr: TSprite );
procedure ChangeSpritePriority( spr: TSprite; n: integer );
procedure CollisionDetection( se: TSpriteEngine );
procedure ProcessSprites;
procedure RenderSprites;
procedure RemoveSprite( spr: TSprite );
property Sprite[n: integer]: TSprite read GetSprite;
property SpriteCount: integer read GetSpriteCount;
published
property DIBDrawingSurface: TDIBDrawingSurface read FDDS write SetDDS;
property DirtyRectangles: boolean read FDirtyRectangles write SetDirty;
property ExpectedSprites: integer read FExpectedSprites write SetExpectedSprites;
property OnCollision: TCollisionEvent read FCollision write FCollision;
end;
procedure Register;